const path = require('path')


let profile = process.argv.find(arg => arg==='prod') ? 'prod' : 'dev' // prod dev

const version = require('fs').readFileSync(__dirname + '/.version', 'utf8')
const logLevel = 'info'

const dbFile = 'torrentmanager.sqlite'

// dev config
const configDev = {
    port:  8080,
    // configPath: 'C:\\Users\\shanke\\WORK\\appdata\\torrentmanager',
    // managePath: 'C:\\Users\\shanke\\WORK',
    // webui: 'C:\\Users\\shanke\\WORK\\ppp\\torrent-manager-web\\dist'
    configPath: '/Users/shanke/Documents/appdata/torrentmanager',
    managePath: '/Users/shanke/Documents',
    webui: '/Users/shanke/Documents/work/ppp/torrent-manager-web/dist'
}

// prod config
const configProd = {
    port: 6699,
    configPath: '/config',
    managePath: '/manage',
    webui: '/web/dist'
}

function getBaseConfig() {
    const baseConfig = {
        profile,
        logLevel,
        version
    }
    if ('dev' === profile)
        return {
            ...baseConfig,
            ...configDev,
            dbUrl: path.join(configDev.configPath, dbFile)
        }
    else if ('prod' === profile)
        return {
            ...baseConfig,
            ...configProd,
            dbUrl: path.join(configProd.configPath, dbFile)
        }
}


const baseConfig = getBaseConfig()


module.exports = baseConfig